package com.tarena.luban.worker.server.controller;

import com.tarena.luban.worker.server.bo.WorkerBO;
import com.tarena.luban.worker.server.controller.assemble.WorkerAssemble;
import com.tarena.luban.worker.server.controller.vo.WorkerVO;
import com.tarena.luban.worker.server.manange.WorkerServerService;
import com.tarena.tp.luban.worker.server.dto.param.WorkerCreateParam;
import com.tedu.inn.protocol.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 前台师傅接口
 1. 入住 写操作
 2. 查询详情,查询的是已经审核通过的当前登录的师傅信息
 */
@RestController
@RequestMapping("/worker")
public class WorkerServerController {
    @Autowired
    private WorkerServerService workerServerService;
    /**
     * 返回 通用数据result
     */
    @PostMapping("/create")
    public Long createWorker(@RequestBody WorkerCreateParam workerCreateParam) throws BusinessException {
        //调用 worker service 新增
        return workerServerService.create(workerCreateParam);
    }
    @Autowired
    private WorkerAssemble workerAssemble;
    /**
     * 师傅详情
     */
    @GetMapping("/detail")
    public WorkerVO workerDetail() throws BusinessException {
        //控制层调用业务层进行查询 查询返回结果是BO
        WorkerBO workerBO=workerServerService.getWorkerDetail();
        return workerAssemble.assembleBO2VO(workerBO);
    }
}
